package com.spring.boot.rabbit.service.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.spring.boot.rabbit.constant.QueueConstant.TOPIC_QUEUE_SECONDARY;

/**
 * topic exchange验证routing-key处理机制
 *
 * @author 李坤
 * @date 2022/9/1 11:52
 */
@Service
public class RabbitConsumerTopic {

    /**
     * 日志处理器
     */
    private final Logger logger = LoggerFactory.getLogger(RabbitConsumerTopic.class);

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * direct exchange binding queue listener one
     *
     * @param message 消息队列中的消息
     */
    @RabbitListener(queues = {TOPIC_QUEUE_SECONDARY})
    public void directExchangeBindingQueueListenerOne(String message) {
        logger.info("topic exchange secondary queue one: " + message);
    }

    /**
     * direct exchange binding queue listener two
     *
     * @param message 消息队列中的消息
     */
    @RabbitListener(queues = {TOPIC_QUEUE_SECONDARY})
    public void directExchangeBindingQueueListenerTwo(String message) {
        logger.info("topic exchange secondary queue two: " + message);
    }

    /**
     * direct exchange binding queue listener three
     *
     * @param message 消息队列中的消息
     */
    @RabbitListener(queues = {TOPIC_QUEUE_SECONDARY})
    public void directExchangeBindingQueueListenerThree(String message) {
        logger.info("topic exchange secondary queue three: " + message);
    }

}
